Add TAL-Reverb-II plugin to test
[juce-lv2.git] / juce / source / extras / the jucer / src / model / components / jucer_HyperlinkButtonHandler.h
blob0761f0465d5cedcd497df5303483be5f9bf23fe2
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCER_HYPERLINKBUTTONHANDLER_JUCEHEADER__
27 #define __JUCER_HYPERLINKBUTTONHANDLER_JUCEHEADER__
29 #include "jucer_ButtonHandler.h"
32 //==============================================================================
33 /**
35 class HyperlinkButtonHandler : public ButtonHandler
37 public:
38 //==============================================================================
39 HyperlinkButtonHandler()
40 : ButtonHandler ("Hyperlink Button", "HyperlinkButton", typeid (HyperlinkButton), 150, 24)
42 registerColour (HyperlinkButton::textColourId, "text", "textCol");
45 //==============================================================================
46 Component* createNewComponent (JucerDocument*)
48 HyperlinkButton* hb = new HyperlinkButton ("new hyperlink", URL ("http://www.rawmaterialsoftware.com/juce"));
50 setNeedsButtonListener (hb, false);
51 return hb;
54 void getEditableProperties (Component* component, JucerDocument& document, Array <PropertyComponent*>& properties)
56 HyperlinkButton* const hb = (HyperlinkButton*) component;
58 ButtonHandler::getEditableProperties (component, document, properties);
60 properties.add (new HyperlinkURLProperty (hb, document));
62 addColourProperties (component, document, properties);
65 XmlElement* createXmlFor (Component* comp, const ComponentLayout* layout)
67 HyperlinkButton* const hb = (HyperlinkButton*) comp;
69 XmlElement* const e = ButtonHandler::createXmlFor (comp, layout);
71 e->setAttribute ("url", hb->getURL().toString (false));
73 return e;
76 bool restoreFromXml (const XmlElement& xml, Component* comp, const ComponentLayout* layout)
78 HyperlinkButton* const hb = (HyperlinkButton*) comp;
80 if (! ButtonHandler::restoreFromXml (xml, comp, layout))
81 return false;
83 hb->setURL (URL (xml.getStringAttribute ("url", hb->getURL().toString (false))));
85 return true;
88 const String getCreationParameters (Component* comp)
90 HyperlinkButton* const hb = dynamic_cast <HyperlinkButton*> (comp);
92 return quotedString (hb->getButtonText())
93 + ",\nURL ("
94 + quotedString (hb->getURL().toString (false))
95 + ")";
98 void fillInCreationCode (GeneratedCode& code, Component* component, const String& memberVariableName)
100 ButtonHandler::fillInCreationCode (code, component, memberVariableName);
102 code.constructorCode << getColourIntialisationCode (component, memberVariableName)
103 << '\n';
106 private:
107 //==============================================================================
108 class HyperlinkURLProperty : public ComponentTextProperty <HyperlinkButton>
110 public:
111 HyperlinkURLProperty (HyperlinkButton* component_, JucerDocument& document_)
112 : ComponentTextProperty <HyperlinkButton> ("URL", 512, false, component_, document_)
115 //==============================================================================
116 void setText (const String& newText)
118 document.perform (new HyperlinkURLChangeAction (component, *document.getComponentLayout(), URL (newText)),
119 "Change hyperlink URL");
122 const String getText() const
124 return component->getURL().toString (false);
127 private:
128 class HyperlinkURLChangeAction : public ComponentUndoableAction <HyperlinkButton>
130 public:
131 HyperlinkURLChangeAction (HyperlinkButton* const comp, ComponentLayout& layout, const URL& newState_)
132 : ComponentUndoableAction <HyperlinkButton> (comp, layout),
133 newState (newState_)
135 oldState = comp->getURL();
138 bool perform()
140 showCorrectTab();
141 getComponent()->setURL (newState);
142 changed();
143 return true;
146 bool undo()
148 showCorrectTab();
149 getComponent()->setURL (oldState);
150 changed();
151 return true;
154 URL newState, oldState;
161 #endif // __JUCER_HYPERLINKBUTTONHANDLER_JUCEHEADER__